// 游戏核心数据类型定义

export interface Player {
  id: string;
  name: string;
  level: number;
  realm: Realm;
  experience: number;
  maxExperience: number; // 当前等级所需最大经验值
  health: number;
  maxHealth: number;
  mana: number;
  maxMana: number;
  attack: number;
  defense: number;
  speed: number;
  avatar: string;
  gold: number; // 金币
  createdAt: Date;
  lastLoginAt: Date;
}

export interface Realm {
  id: string;
  name: string;
  level: number;
  description: string;
  requiredExp: number;
  bonusStats: {
    health: number;
    mana: number;
    attack: number;
    defense: number;
    speed: number;
  };
}

export interface Skill {
  id: string;
  name: string;
  description: string;
  type: 'attack' | 'defense' | 'heal' | 'buff';
  level: number;
  maxLevel: number;
  manaCost: number;
  damage?: number;
  healAmount?: number;
  cooldown: number;
  requiredRealm: number;
}

export interface Item {
  id: string;
  name: string;
  description: string;
  type: 'weapon' | 'armor' | 'accessory' | 'consumable' | 'material';
  rarity: 'common' | 'uncommon' | 'rare' | 'epic' | 'legendary';
  stats?: {
    attack?: number;
    defense?: number;
    health?: number;
    mana?: number;
    speed?: number;
  };
  price: number;
  stackable: boolean;
  maxStack?: number;
}

export interface Equipment {
  weapon?: Item;
  armor?: Item;
  accessory?: Item;
}

export interface Quest {
  id: string;
  title: string;
  description: string;
  type: 'main' | 'side' | 'daily';
  status: 'available' | 'active' | 'completed';
  requirements: {
    level?: number;
    realm?: number;
    items?: { id: string; quantity: number }[];
    kills?: { enemyId: string; quantity: number }[];
  };
  rewards: {
    experience: number;
    gold: number;
    items?: { id: string; quantity: number }[];
  };
  progress: number;
  maxProgress: number;
}

export interface Enemy {
  id: string;
  name: string;
  level: number;
  health: number;
  maxHealth: number;
  attack: number;
  defense: number;
  speed: number;
  skills: string[];
  rewards: {
    experience: number;
    gold: number;
    items?: { id: string; quantity: number; dropRate: number }[];
  };
}

export interface BattleState {
  player: Player;
  enemy: Enemy;
  turn: 'player' | 'enemy';
  round: number;
  playerSkillCooldowns: Record<string, number>;
  enemySkillCooldowns: Record<string, number>;
  battleLog: string[];
  status: 'active' | 'victory' | 'defeat';
}

export interface GameState {
  player: Player;
  inventory: { item: Item; quantity: number }[];
  equipment: Equipment;
  skills: Skill[];
  quests: Quest[];
  gold: number;
  settings: {
    soundEnabled: boolean;
    musicEnabled: boolean;
    autoSave: boolean;
  };
}